#include "threadPool.hpp"
#include <ctime>
#include "Task.hpp"

int main()
{
    srand((unsigned long)time(NULL) ^ getpid());

    ThreadPool<Task> *tp = ThreadPool<Task>::getInstance(); // 获取单例
    tp->run();
    int count = 0;
    while (count++ < 100)
    {
        int x = rand() % 100 + 1;
        int y = rand() % 100 + 1;
        Task t(x, y, [](int x, int y) -> int
               {
                int ret=x * y;
                return ret; }); // 制作任务
        tp->pushTask(t);
        logMessage(WARNING, "[%ld]制作任务%d*%d=?|%s|%d\n", time(NULL), x, y, __FILE__, __LINE__);
        // sleep(1);
    }

    delete tp;
    return 0;
}